package com.briup.corejava.chap09.bean;

import com.briup.corejava.chap09.exception.AgeOutOfRangeException;

public class Student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception{
        if(age >= 0 && age <= 100){
            this.age = age;
        }else {
            throw new AgeOutOfRangeException("年龄不符合要求");
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
